// pkg_doctors/pages/doctor/doctor.js
import request from '../../../utils/http.js'
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    service: [],
    ysid: 0,
    xingMing: "",//医师姓名
    zhiYeYiShi: "",//执业
    zhaoPian1Url: '',//头像
    jieShao: "",//医师介绍
    fuWuBaoList: [],
    zhiNanList: [],
    fuWuBaoListlength: 0,
    zhiNanListlength: 0,
    personId: 0,
    tjr_id: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    var that = this
    that.setData({
      ysid: options.ysid,
      personId: wx.getStorageSync(app.globalData.PERSON_ID),
      tjr_id: 0,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },


  //获取医生详情
  yiShengOne: function () {
    var that = this
    let data = {
      id: that.data.ysid,
    }
    request.get('yiSheng/yiShengOne', data, res => {
      console.log("获取医生详情:" + JSON.stringify(res.data))
      that.setData({
        zhiYeYiShi: res.data.item.zhiYeYiShi,
        xingMing: res.data.item.xingMing,
        zhaoPian1Url: res.data.item.zhaoPian1Url,
        jieShao: res.data.item.jieShao.replace(/<p /g, '<p class="jieshaoCSS"'),
        zhiNanList: res.data.zhiNanList,
        fuWuBaoListlength: res.data.fuWuBaoList.length,
        zhiNanListlength: res.data.zhiNanList.length,
        fuWuBaoList: res.data.fuWuBaoList
      })
    }, err => {
      wx.showToast({
        title: '获取信息失败', // 提示的内容
        icon: "none", // 图标，默认success
        duration: 1000, // 提示的延迟时间，默认1500
        mask: false, // 是否显示透明蒙层，防止触摸穿透
      })
    })
  },

  //跳转指南详情
  toInfo: function (e) {
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pkg_doctors/pages/zhinan/details?id=' + id,
    })
  },

  //产品详情页
  toProductInfo: function (e) {
    var productId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/product_info_fwb/product_info_fwb?productId=' + productId
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.yiShengOne()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})